﻿using Engine;
using Game;

namespace Mekiasm
{
    public class SolarPanelWidget : BaseEnergyWidget
    {
        public ComponentSolarPanel generator;
        public LabelWidget labelWidget = new LabelWidget() { Size = new Vector2(100, 32), FontScale = 0.5f };
        public InventorySlotWidget inventory1;
        public StackPanelWidget mStackCenter = new StackPanelWidget() { Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center, VerticalAlignment = WidgetAlignment.Center };
        public SolarPanelWidget(ComponentSolarPanel componentCoalGenerator, ComponentMiner componentMiner) : base(componentMiner)
        {
            generator = componentCoalGenerator;
            inventory1 = new InventorySlotWidget() { Size = new Vector2(48, 48), Margin = new Vector2(0, 10), BevelColor = Color.Red };
            inventory1.AssignInventorySlot(generator, 0);
            mStackCenter.Children.Add(inventory1);
            mStackCenter.Children.Add(labelWidget);
            CanvasMain.Children.Add(mStackCenter);
            setTitle("太阳能发电机");
        }

        public override void Update()
        {
            SetPowerProgress((float)generator.Power / generator.MaxPower);
            SetLeftBottomMoreInfo($"产能: {ILibrary.FormatPower(generator.InputPowerLimit)}\n输出:{ILibrary.FormatPower(generator.OutputPowerLimit)}\n当前:{ILibrary.FormatPower(generator.Power)}\n最大:{ILibrary.FormatPower(generator.MaxPower)}");
        }

    }
}
